#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>

struct List {
    int data;
    struct List* next;
};

struct List* creatList(int x) {
    struct List* newnode = (struct List*)malloc(sizeof(struct List));
    newnode->data = x;
    newnode->next = NULL;

    return newnode;
}


int main() {
    int n = 0;
    scanf("%d", &n);
    int num = 0;
    scanf("%d", &num);
    struct List* phead = creatList(num);
    struct List* cur = phead;
    for (int i = 1; i < n; i++) {
        scanf("%d", &num);
        cur->next = creatList(num);;
        cur = cur->next;
    }
    int x = 0;
    scanf("%d", &x);
    struct List* prev = NULL;
    struct List* fast = phead;
    while (fast) {
        if (fast->data == x) {
            prev->next = fast->next;
            free(fast);
        }
        else
            prev = fast;
    }
    while (phead) {
        printf("%d ", phead->data);
        phead = phead->next;
    }

    return 0;
}